<?php
class ASolicitudRepuestosAdicional{
	public function descuentoAlmacen(EFacade & $facade)
	{
		$doc = & $facade->getDocumentRoot();
		$ezpdo_=getManager();
		$session = & $facade->getSession();
		$role=NULL;		

		/********* Disparar la OM **********/
		$OM = $doc->ordenMantenimiento;
		$workflow = & $OM->getWorkflowRef();
		$facade->session->refresh($workflow);
		$newEfacade = & EFacade :: initWorkflowWithoutRole($facade->session, $OM, 3);//tipo Process
		$transSet = & EFacade :: getCurrentTransSetAuto($workflow, /*PROCESS */ 3);
		$trans = $transSet->getTransByName('t7');
		$role = null;
		if($trans)
			$newEfacade->fireTrans($trans, $role, "Culmina",TRUE);
		$workflow->epSetDirty(TRUE);
		$OM->epSetDirty(TRUE);
		$newEfacade->saveWorkflow();
		
		$doc->epSetDirty(TRUE);
	    $doc->commit();
		$workflow = & $facade->getWorkflow();
		$workflow->epSetDirty(TRUE);
		$transSet = & EFacade :: getCurrentTransSetAuto($workflow, 2); //TYPE AUTO AGENT		
		$trans = $transSet->getTransByName('t3');
		$facade->fireTrans($trans,$role,'Terminar Orden Repuestos Adicional', TRUE);		
	}
	public function culminarSolicitud(EFacade & $facade)
	{
		$docOTM = & $facade->getDocumentRoot();
		$docOTM->epSetDirty(TRUE);
	    $docOTM->commit();
		$workflowSA = & $facade->getWorkflow();
		$workflowSA->epSetDirty(TRUE);
		$transSetSA = & EFacade :: getCurrentTransSetAuto($workflowSA, 2); //TYPE AUTO AGENT		
		$transSA = $transSetSA->getTransByName('t5');
		$role = null;
		$facade->fireTrans($transSA,$role,'Terminar Orden Repuestos Adicional', TRUE);		
	}	
}
?>